<template>
    <div class="nest">
        <el-form class="search-form" inline size="mini">
            <el-form-item>
                <el-input v-model="search.title" placeholder="提现单号" clearable @change="getList" />
            </el-form-item>
            <el-form-item>
                <el-input v-model="search.title" placeholder="用户id" clearable @change="getList" />
            </el-form-item>
            <el-form-item>
                <el-input v-model="search.title" placeholder="用户昵称" clearable @change="getList" />
            </el-form-item>
            <el-form-item>
                <el-select v-model="search.state" placeholder="提现状态" clearable @change="getList">
                    <el-option label="待审核" value="1" />
                    <el-option label="已提现" value="2" />
                    <el-option label="已拒绝" value="2" />
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">查询</el-button>
                <el-button icon="el-icon-refresh-left" size="mini" @click="handleResetSearch">重置</el-button>
            </el-form-item>
            <!-- <addClassify ref="addClassify" @success="getList"></addClassify> -->
        </el-form>
        <div class="table">
            <el-table :data="tableData" style="width: 100%;margin-bottom: 20px;" v-loading="loading">
                <el-table-column prop="id" label="提现单号" show-overflow-tooltip>
                </el-table-column>
                <el-table-column prop="id" label="用户ID" show-overflow-tooltip>
                </el-table-column>
                <el-table-column prop="id" label="用户昵称" show-overflow-tooltip>
                </el-table-column>
                <el-table-column prop="id" label="账号余额" show-overflow-tooltip>
                </el-table-column>
                <el-table-column prop="id" label="提现金额" show-overflow-tooltip>
                </el-table-column>
                <el-table-column prop="id" label="提现状态" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ "提现成功" }}
                    </template>
                </el-table-column>
                <el-table-column prop="id" label="提现时间" show-overflow-tooltip>
                </el-table-column>
                <el-table-column prop="id" label="审核时间" show-overflow-tooltip>
                </el-table-column>
                <el-table-column label="操作" width="200">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="audit">审核</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div style="text-align: right;">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="search.page" :page-sizes="[10, 20, 30, 40, 100]" :page-size="search.size" background
                    layout="total, sizes, prev, pager, next" :total="total">
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import addClassify from "./addClassify.vue"

export default {
    components: { addClassify },
    data() {
        return {
            loading: false,
            search: {
                title: "",	//true	string		名称
                state: "",	//true	string		状态 0 全部 1 启用 2 禁用
                page: 1,	//true	int		当前页
                size: 10,	//true	int		每页多少条
            },
            tableData: [],
            total: 0
        }
    },
    created() {
        this.getList()
    },
    methods: {
        audit() { // 审核
            this.$prompt('审核完成将自动打款，请确认', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: "",
                inputErrorMessage: "请输入备注",
                type: 'warning'
            }).then(() => {
            }).catch(() => {
            });
        },
        // 删除分类
        nestDelete(data) {
            this.$confirm(`确认删除品种【${data.title}】吗？`, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async () => {
                let res = await this.$request({
                    url: '/admin/pet.category/delete',
                    method: 'post',
                    data: { id: data.id }
                })
                if (res.code == 200) {
                    this.$message.success("删除成功")
                    this.getList()
                }
            })
        },
        // 修改分类状态
        async updataState(data) {
            let res = await this.$request({
                url: '/admin/pet.category/state',
                method: 'post',
                data: { id: data.id }
            })
            if (res.code == 200) {
                this.$message.success("操作成功")
            }
        },
        // 分类列表
        async getList() {
            this.loading = true
            let res = await this.$request({
                url: '/admin/pet.category/index',
                method: 'get',
                params: this.search
            })
            this.loading = false
            if (res.code == 200) {
                this.tableData = res.result.data
                this.total = res.result.total
            }
        },
        handleResetSearch() {
            this.search = {
                title: "",	//true	string		名称
                state: "",	//true	string		状态 0 全部 1 启用 2 禁用
                page: 1,	//true	int		当前页
                size: 10,	//true	int		每页多少条
            }
        },
        //分页
        handleSizeChange(e) {
            this.search.size = e;
            this.getList()
        },
        handleCurrentChange(e) {
            this.search.page = e;
            this.getList()
        },
    }
}
</script>

<style lang="scss">
.nest {
    width: 100%;
    height: 60px;

    .search-form {
        background: #fff;
        border-radius: 12px;
        padding: 12px 20px;
        margin-bottom: 20px;

        .el-form-item--mini.el-form-item {
            margin-bottom: 0;
        }
    }

    .table {
        padding: 12px 20px;
        background: #fff;
    }
}
</style>
